<template>
  <div class="community">
    <div class="header">
      <div class="title">社区</div>
      <div class="search-bar">
        <input type="text" placeholder="搜索">
        <button>搜索</button>
      </div>
    </div>
    <div class="post-list">
      <div v-for="post in posts" :key="post.id" class="post">
        <div class="post-header">
          <img :src="post.userAvatar" alt="user-avatar" width="50px">
          <div class="user-info">
            <div class="username">{{ post.username }}</div>
            <div class="post-time">{{ post.time }}</div>
          </div>
        </div>
        <div class="post-content">{{ post.content }}</div>
        <div class="post-actions">
          <button>点赞</button>
          <button>评论</button>
          <button>分享</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      posts: [
        {
          id: 1,
          username: '船长',
          userAvatar: '/public/头像.jpg',
          time: '1小时前',
          content: '分享一首歌曲 船长-赵雷'
        },
        {
          id: 2,
          username: '郭源潮',
          userAvatar: 'https://tse2-mm.cn.bing.net/th/id/OIP-C.gYHPRQTqb8DWNJqmZXxSZAAAAA?w=167&h=180&c=7&r=0&o=5&dpr=1.5&pid=1.7',
          time: '2小时前',
          content: '分享一首歌曲 关忆北-宋东野'
        },
        {
          id: 3,
          username: '不吃香菜',
          userAvatar: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.L7gIF6kG4EHMyr1en6RyfwAAAA?w=188&h=180&c=7&r=0&o=5&dpr=1.5&pid=1.7.jpg',
          time: '3小时前',
          content: '分享一首歌曲 但-草东没有派对'
        },
        {
          id: 4,
          username: '行迹',
          userAvatar: 'https://tse4-mm.cn.bing.net/th/id/OIP-C.F1B36Q4hlEE7yAoNCcfjOgAAAA?w=203&h=203&c=7&r=0&o=5&dpr=1.5&pid=1.7',
          time: '4小时前',
          content: '分享一首歌曲 杀死那个石家庄人-万能青年旅社'
        }
      ]
    }
  }
}
</script>

<style scoped>
.community {
  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: #f5f5f5;
    .title {
      font-size: 20px;
      font-weight: bold;
    }
    .search-bar {
      input {
        padding: 5px;
        margin-right: 5px;
      }
      button {
        padding: 5px 10px;
        background-color: #00bcd4;
        color: #fff;
        border: none;
        cursor: pointer;
      }
    }
  }
  .post-list {
    .post {
      padding: 10px;
      margin-bottom: 10px;
      background-color: #fff;
      .post-header {
        display: flex;
        align-items: center;
        img {
          width: 40px;
          height: 40px;
          border-radius: 50%;
          margin-right: 10px;
        }
        .user-info {
          .username {
            font-weight: bold;
          }
          .post-time {
            color: #666;
          }
        }
      }
      .post-actions {
        button {
          padding: 5px 10px;
          margin-right: 10px;
          border: 1px solid #ccc;
          cursor: pointer;
        }
      }
    }
  }
}
</style>